/* SPDX-License-Identifier: GPL-2.0 */

#ifndef IB_HW_COMPAT_H
#define IB_HW_COMPAT_H

#include <linux/cdev.h>
#include "core_priv.h"

struct ib_hw_event_handler {
	struct ib_device *device;
	void (*handler)(struct ib_hw_event_handler *handler, struct ib_hw_event *event);
	struct list_head  list;
};

enum {
	IB_HW_COMPAT_MAX_DEVICES = RDMA_MAX_PORTS,
	IB_HW_COMPAT_NUM_DYNAMIC_MINOR = IB_HW_COMPAT_MAX_DEVICES,
};

struct ib_hw_compat_device {
	struct kobject kobj;
	struct cdev cdev;
	struct list_head file_list;
	struct mutex list_mutex;
	struct ib_device __rcu *ib_dev;
	struct srcu_struct disassociate_srcu;
	int devnum;
	struct device *dev;
};

struct ib_hw_event_queue {
	spinlock_t lock;
	int is_closed;
	wait_queue_head_t poll_wait;
	struct list_head event_list;
};

struct ib_hw_compat_file {
	struct kref ref;
	struct file *filp;
	struct ib_hw_compat_device *device;
	struct list_head list;
	struct ib_hw_event_queue event_queue;
	struct ib_hw_event_handler event_handler;
};

struct ib_hw_compat_event {
	struct list_head list;
	uint32_t type;
	int len;
	u8 data[0];
};

#endif /* IB_HW_COMPAT_H */
